import { _decorator, Button, Component, Node, director, AudioClip } from 'cc';
const { ccclass, property } = _decorator;
import { GameManager, GameStatus } from './GameManager';
import { AudioMgr } from './AudioMgr';

@ccclass('GameEndUI')
export class GameEndUI extends Component {
  @property({ type: AudioClip })
  GameOverAudioClip: AudioClip
  start() {
    this.controlActive()
    AudioMgr.inst.stop()
    AudioMgr.inst.playOneShot(this.GameOverAudioClip)
  }

  update(deltaTime: number) {

  }
  showGameEndUI() {
    this.node.active = true
  }
  hideGameEndUI() {
    this.node.active = false
  }
  controlActive() {
    if (GameManager.status === GameStatus.GameEnd) {
      this.showGameEndUI()
    }
    else {
      this.hideGameEndUI()
    }
  }
  onClick() {
    director.loadScene(director.getScene().name)
  }
}


